package com.andy.controller;

import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.andy.service.IStudentService;
import com.andy.vo.ExamScoreVO;
import com.andy.vo.ExamSubjectVO;
import com.andy.vo.ExamUserVO;

@Controller
@RequestMapping(value = "/student")
public class StudentController {
	
	@Autowired
	private IStudentService studentService;

	@RequestMapping(value = "/subjects")
	public String toSubjects(HttpSession session, Model model) {
		ExamUserVO userVO = (ExamUserVO) session.getAttribute("examUser");
		List<ExamSubjectVO> exmaSubjectList = studentService.getSubjectList(userVO);
		model.addAttribute("exmaSubjectList", exmaSubjectList);
		return "student/subjects";
	}
	
	@ResponseBody
	@RequestMapping(value = "/showScore", method = RequestMethod.POST)
	public ExamScoreVO showScore(HttpSession session, Integer scoreId) {
		ExamScoreVO vo = studentService.getScoreById(scoreId);
		return vo;
	}
	
}
